package com.ruoyi.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.order.domain.TbOrderManual;
import com.ruoyi.order.service.ITbOrderManualService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 人工派单记录Controller
 * 
 * @author ruoyi
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/manual")
public class TbOrderManualController extends BaseController
{
    @Autowired
    private ITbOrderManualService tbOrderManualService;

    /**
     * 查询人工派单记录列表
     */
    //@RequiresPermissions("order:manual:list")
    @GetMapping("/list")
    public TableDataInfo list(TbOrderManual tbOrderManual)
    {
        startPage();
        List<TbOrderManual> list = tbOrderManualService.selectTbOrderManualList(tbOrderManual);
        return getDataTable(list);
    }

    /**
     * 导出人工派单记录列表
     */
    //@RequiresPermissions("order:manual:export")
    @Log(title = "人工派单记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbOrderManual tbOrderManual)
    {
        List<TbOrderManual> list = tbOrderManualService.selectTbOrderManualList(tbOrderManual);
        ExcelUtil<TbOrderManual> util = new ExcelUtil<TbOrderManual>(TbOrderManual.class);
        util.exportExcel(response, list, "人工派单记录数据");
    }

    /**
     * 获取人工派单记录详细信息
     */
    //@RequiresPermissions("order:manual:query")
    @GetMapping(value = "/{manualId}")
    public AjaxResult getInfo(@PathVariable("manualId") Long manualId)
    {
        return success(tbOrderManualService.selectTbOrderManualByManualId(manualId));
    }

    /**
     * 新增人工派单记录
     */
    //@RequiresPermissions("order:manual:add")
    @Log(title = "人工派单记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbOrderManual tbOrderManual)
    {
        return toAjax(tbOrderManualService.insertTbOrderManual(tbOrderManual));
    }

    /**
     * 修改人工派单记录
     */
    //@RequiresPermissions("order:manual:edit")
    @Log(title = "人工派单记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbOrderManual tbOrderManual)
    {
        return toAjax(tbOrderManualService.updateTbOrderManual(tbOrderManual));
    }

    /**
     * 删除人工派单记录
     */
    //@RequiresPermissions("order:manual:remove")
    @Log(title = "人工派单记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{manualIds}")
    public AjaxResult remove(@PathVariable Long[] manualIds)
    {
        return toAjax(tbOrderManualService.deleteTbOrderManualByManualIds(manualIds));
    }
}
